<form class="layui-form" lay-filter="member-member-add-form" id="member-member-add-form" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-inline">
            <input type="text" name="username" lay-verify="required" lay-reqText="用户名不能为空" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">选择用户组</label>
        <div class="layui-input-inline">
            <script type="text/html" template lay-url="{{ layui.setter.apiHost }}/member/group/select" lay-done="layui.form.render();">
                <select name="group_id" lay-verify="required" lay-reqText="请选择用户组">
                    <option value=""></option>
                    {{# layui.each(d.data, function(index, item){ }}
                    <option value="{{ index }}" {{# if(index== d.params.group_id){ }}selected{{# } }}>{{ item }}</option>
                    {{# }); }}
                </select>
            </script>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" id="password" lay-verify="password" autocomplete="off" class="layui-input" placeholder="不修改请留空">
        </div>
        <label class="layui-form-label">重复密码</label>
        <div class="layui-input-inline">
            <input type="password" name="repeat_password" lay-verify="resspaword" autocomplete="off" class="layui-input" placeholder="不修改请留空">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <button type="button" class="layui-btn layui-btn-sm plupload_btn" id="seller-seller-add-up_image">选择图片</button>
        <script type="text/html" template>
            <a href="{{ d.params.headimg || '' }}" target="_blank">
                <img src="{{ d.params.headimg || '' }}" width="50" class="{{ d.params.headimg || 'layui-hide' }}">
            </a>
            <input type="hidden" value="{{ d.params.headimg || '' }}" name="headimg">
        </script>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-inline">
            <input type="text" name="nickname" lay-verify="required" lay-reqText="昵称不能为空" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="full_name" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话</label>
        <div class="layui-input-inline">
            <input type="text" name="tel" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="email" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="0" title="未知" lay-verify="required">
            <input type="radio" name="sex" value="1" title="男" lay-verify="required">
            <input type="radio" name="sex" value="2" title="女" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地区</label>
        <div class="layui-input-inline">
            <select name="prov_id" id="prov_id" lay-filter="prov_id">
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="city_id" id="city_id" lay-filter="city_id">
            </select>
        </div>
        <div class="layui-input-inline">
            <select name="area_id" id="area_id" lay-filter="area_id">
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline">
            <input type="hidden" name="id" value="">
            <input type="button" lay-submit lay-filter="member-member-add-form-submit" value="确认" class="layui-btn">
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="text/html" template lay-done="layui.data.sendParams(d.params)"></script>
<script language="JavaScript" src="../src/lib/plupload/plupload.full.min.js"></script>
<script language="JavaScript" src="../src/lib/plupload/i18n/zh_CN.js"></script>
<script>
    layui.data.sendParams = function (params) {
        layui.use(['common', 'admin', 'form', 'laytpl', 'plupload'], function () {
            var common = layui.common,
                admin = layui.admin,
                form = layui.form,
                laytpl = layui.laytpl,
                $ = layui.jquery,
                plupload = layui.plupload;

            plupload.upload();//初始化图片上传

            //自定义验证规则
            form.verify({
                password: function (value) {
                    var id = $('input[name="id"]').val();
                    var password = /^[\S]{6,12}$/;
                    var r = value.match(password);
                    if (r == null && !params.id) {
                        return '密码必须6到12位，且不能出现空格';
                    }
                },
                resspaword: function (value) {
                    var pass = $('input[name="password"]').val();
                    if (value != pass) {
                        return '两次密码不一致';
                    }
                }
            });

            //设置默认省市区
            common.set_default_area(params.prov_id, params.city_id, params.area_id);
            //监听省份选择
            form.on('select(prov_id)', function (data) {
                common.get_area('city_id', data.value);
            });
            //监听城市选择
            form.on('select(city_id)', function (data) {
                common.get_area('area_id', data.value);
            });
        })
    };
</script>